<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Overlapping Text Effect</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='style.css'>
</head>
<body>
<h1 class="overlap overlap__front">Hello World!</h1>
<h1 class="overlap overlap__back">Hello World!</h1>
<script>
const overlapEls = document.querySelectorAll(".overlap") || [];
overlapEls.forEach((el) => {
const chars = [...el.textContent];
el.innerHTML = "";
chars.forEach((char, index) => {
const span = document.createElement("span");
span.textContent = char;
span.style.setProperty("--index", index);
el.append(span);
});
});
</script>
</body>
</html>